<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const new21Game = (n, k, c) => {
      if (k === 0 || n >= k + c) return 1;
      let dp = [1], a = 1, res = 0;
      for (let i = 1; i <= n; i++) {
        dp[i] = a / c;
        if (i < k) a += dp[i];
        else res += dp[i];
        if (i - c >= 0) a -= dp[i - c];
      }
      return res;
    };
    console.log(new21Game(n = 21, k = 17, c = 10));
  </script>

</body>

</html>